package com.innovation.chengzhangriji.ui;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.innovation.chengzhangriji.R;
import com.innovation.chengzhangriji.ui.widget.CuteEditText;
import com.innovation.chengzhangriji.ui.widget.CuteToolbar;

public class BabyDetailChangeActivity extends BaseActivity implements CuteToolbar.OnClickCuteToolbarListener  {
    private CuteEditText editText;
    private String name;
    private int from=-1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_baby_detail_change);
        CuteToolbar toolbar = (CuteToolbar) findViewById(R.id.baby_detail_change_toolbar);
        toolbar.setOnClickCuteToolbarListener(this);
        editText = (CuteEditText) findViewById(R.id.edittext_babydetailchange);
        Intent intent =getIntent();
        name = intent.getStringExtra("name");
        from = intent.getIntExtra("from",-1);
        editText.setText(name);
        editText.setSelection(name.length());
        if (from ==1 ){
            toolbar.setCuteTitle("宝宝小名");
        }else{
            toolbar.setCuteTitle("宝宝姓名");
        }
    }

    @Override
    public void onClickLeft() {
        onBackPressed();
    }

    @Override
    public void onClickRight() {
        Intent resultIntent = new Intent();
        resultIntent.putExtra("name",editText.getText().toString().trim());
        setResult(RESULT_OK, resultIntent);
        finish();
    }
}
